package com.thd.framework.db.configuration;


import com.baomidou.mybatisplus.extension.plugins.MybatisPlusInterceptor;
import com.baomidou.mybatisplus.extension.plugins.inner.PaginationInnerInterceptor;
import com.thd.framework.db.intereptor.MybatisPlusPrintSqlInterceptor;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.transaction.annotation.EnableTransactionManagement;

/**
 * com.thd.springboottest.mybatisplus.config.MybatisPlusConfig
 * mybatis plus 插件配置类
 * @author: wanglei62
 * @DATE: 2019/9/20 17:09
 **/

@EnableTransactionManagement
@Configuration

public class MybatisPlusConfig {

    @Bean
    public MybatisPlusInterceptor paginationInterceptor(){
        MybatisPlusInterceptor mybatisPlusInterceptor = new MybatisPlusInterceptor();
        PaginationInnerInterceptor paginationInnerInterceptor = new PaginationInnerInterceptor();
        // 设置请求的页面大于最大页后操作， true调回到首页，false 继续请求  默认false
        paginationInnerInterceptor.setOverflow(false);
        //设置最大单页限制数量，默认 500 条，-1 最大999条
        paginationInnerInterceptor.setMaxLimit(-1L);
        mybatisPlusInterceptor.addInnerInterceptor(paginationInnerInterceptor);
        return mybatisPlusInterceptor;
    }




    /**
     * 打印SQL
     * @return
     */
    @Bean
    public MybatisPlusPrintSqlInterceptor mybatisSQLInterceptor() {
        return new MybatisPlusPrintSqlInterceptor(false);
    }



}
